<?php 
require('../common/mysql.php');
require('../common/isAdmin.php');
$db = new Sql();  
$Allcate = $db->getAll("SELECT * FROM `category` where status = 0;");

if(!$Allcate){
	echo "<script>alert(\"已经没有待处理的申请了！\");window.location.href = 'index.php'</script>";   
	exit;
}
if($_GET['success']){
	 $db->query("UPDATE `category` SET `status` = '1' WHERE `category`.`id` = {$_GET['success']};");
	echo "<script>alert(\"通过成功！\");window.location.href = ''</script>";  
}
$db->close();  
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>Hadi.申请管理</title>
		<style>
		body{
			background-color:#3CB378;
		}
		.container{
			background-color:white;
			border-radius:10px;
			padding:3px;
			margin:5px;
			text-align:center;
		}
		.btndiv button{
			padding:6px;
			margin:3px;
			border:none;
			border-radius:3px;
		}
		.userDIV{
			padding:5px;
		}
		</style>
	</head>
	<body>
		<div class="container">
			<span style="font-size:20px;">全部申请</span>
			<?php for($i=0;$i<count($Allcate);$i++){?>
				<div class="userDIV" onclick="window.location.href='setuser.php?u=<?php echo $Allcate[$i]["name"];?>'">
				用户申请的分类: <?php echo $Allcate[$i]["name"];?>
				<a style="text-decoration:none;color:blue;" href="?success=<?php echo $Allcate[$i]["id"];?>">通过申请</a>
				</div>
			<?php }?>
		</div>
	</body>
</html>
